package com.example.woke;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;

import com.zhongcai.online.R;

public class AboutActivity extends Activity {

	private String versioname;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_about);
		
		intview();
		
	}
	
	private void makeaphone() {
		final AlertDialog.Builder builder = new AlertDialog.Builder(AboutActivity.this);
		builder.setTitle("呼叫客服");
		builder.setMessage("400-6080-608");
		builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {}
		});
		builder.setPositiveButton("拨通电话", new DialogInterface.OnClickListener() {
			@Override
			public void onClick(DialogInterface dialog, int which) {
				Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:"+"400-6080-608"));
				startActivity(intent);
			}
		});
		AlertDialog alert = builder.create();
		alert.show();
	}
	
	 /**
     * ��ȡ�汾��
	 * @param mTvcode 
     * @return ��ǰӦ�õİ汾��
     */
    public String getVersion(TextView mTvcode) {
        try {
           android.content.pm.PackageManager manager = AboutActivity.this.getPackageManager();
            android.content.pm.PackageInfo info = manager.getPackageInfo(AboutActivity.this.getPackageName(), 0);
            versioname = info.versionName;
            mTvcode.setText("版本号：v"+versioname);
            int versionCode = info.versionCode;
           return ""+versionCode;
       } catch (Exception e) {
           e.printStackTrace();
           return "";
       }
   }

	private void intview() {
		findViewById(R.id.avabout_image_back).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		TextView mTvcode = (TextView) findViewById(R.id.avabout_tel_v);
		getVersion(mTvcode);
		
		findViewById(R.id.avabout_tel_phone).setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				makeaphone();
			}
		});
		
	}
}
